package com.systop.common.modules.security.user.service.listener;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.systop.common.modules.security.acegi.listener.UserLoginListener;
import com.systop.common.modules.security.user.model.User;
import com.systop.common.modules.security.user.service.UserManager;

@Service
public class UserLoginHistoryListener implements UserLoginListener {

	@Autowired
	private UserManager userManager;

	@Override
	public void loginSuccessed(User user, HttpServletRequest request) {
		userManager.addUserLoginHistory(user, request.getRemoteAddr());
	}

	@Override
	public void loginFailed(HttpServletRequest request) {
		// TODO do nothing...
	}
}
